#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
批量更新order表，添加新字段的脚本
"""

import sys
import os

# 添加项目根目录到Python路径
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from db_tools.db_handler import DbHandler

def main():
    """
    主函数：执行批量更新order表的操作
    """
    print("开始批量更新order表...")
    
    try:
        # 创建数据库处理器实例
        db = DbHandler()
        
        # 执行批量更新
        result, message = db.update_all_orders_with_new_fields()
        
        if result == "ok":
            print(f"✅ {message}")
        else:
            print(f"❌ {message}")
            
    except Exception as e:
        print(f"❌ 执行更新时发生错误: {str(e)}")

if __name__ == "__main__":
    main()
